<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Module: ApplicationHelper
  
    &mdash; Documentation by YARD 0.7.3
  
</title>

  <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '';
  if (relpath != '') relpath += '/';
</script>

  <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="js/app.js"></script>


  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html">Index (A)</a> &raquo; 
    
    
    <span class="title">ApplicationHelper</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a id="class_list_link" href="#">Class List</a>
  
    <a id="method_list_link" href="#">Method List</a>
  
    <a id="file_list_link" href="#">File List</a>
  
</div>
      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Module: ApplicationHelper
  
  
  
</h1>

<dl class="box">
  
  
    
  
    
  
  
  
    <dt class="r1 last">Defined in:</dt>
    <dd class="r1 last">app/helpers/application_helper.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>
ELMO - Secure, robust, and versatile data collection. Copyright 2011 The
Carter Center
</p>
<p>
ELMO is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
</p>
<p>
ELMO is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
</p>
<p>
You should have received a copy of the GNU General Public License along
with ELMO. If not, see &lt;http://www.gnu.org/licenses/&gt;.
</p>


  </div>
</div>
<div class="tags">
  

</div>




  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#action_links-instance_method" title="#action_links (instance method)">- (Object) <strong>action_links</strong>(obj, options) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
assembles links for the basic actions in an index table (show edit and
destroy).
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#basic_form-instance_method" title="#basic_form (instance method)">- (Object) <strong>basic_form</strong>(obj, &amp;block) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
draws a basic form for the given object.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#batch_op_link-instance_method" title="#batch_op_link (instance method)">- (Object) <strong>batch_op_link</strong>(options) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
creates a link to a batch operation options include :action (e.g.
forms#add_questions), :id, :format, :name (name of the link).
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#button_to_if_auth-instance_method" title="#button_to_if_auth (instance method)">- (Object) <strong>button_to_if_auth</strong>(label, url, action, object = nil, *args) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
same as link_to_if_auth but for button_to.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#fix_error_messages-instance_method" title="#fix_error_messages (instance method)">- (Object) <strong>fix_error_messages</strong>(msgs) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
applies any customizations to automatically generated form error messages
called from layouts/flash.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#flash_and_form_errors-instance_method" title="#flash_and_form_errors (instance method)">- (Object) <strong>flash_and_form_errors</strong>(object = nil) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
renders the flash message and any form errors for the given activerecord
object.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#index_table-instance_method" title="#index_table (instance method)">- (Object) <strong>index_table</strong>(klass, objects) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
renders an index table for the given class and list of objects.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#join_links-instance_method" title="#join_links (instance method)">- (Object) <strong>join_links</strong>(*links) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
joins a set of links together with pipe characters, ignoring any blank ones
for use with link_to_if_auth.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#link_to_if_auth-instance_method" title="#link_to_if_auth (instance method)">- (Object) <strong>link_to_if_auth</strong>(label, url, action, object = nil, *args) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
renders a link only if the current user is authorized for the specified
action.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#place_field-instance_method" title="#place_field (instance method)">- (Object) <strong>place_field</strong>(form) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
renders a place field in a form.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#reqd_sym-instance_method" title="#reqd_sym (instance method)">- (Object) <strong>reqd_sym</strong>(condition = true) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
renders the standard &#8216;required&#8217; symbol, which is an asterisk.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#select_all_link-instance_method" title="#select_all_link (instance method)">- (Object) <strong>select_all_link</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
creates a link to select all the checkboxes in an index table.
</p>
</div></span>
  
</li>

      
    </ul>
  



  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="action_links-instance_method">
  
    - (<tt>Object</tt>) <strong>action_links</strong>(obj, options) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
assembles links for the basic actions in an index table (show edit and
destroy)
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 72</span>

<span class='def def kw'>def</span> <span class='action_links identifier id'>action_links</span><span class='lparen token'>(</span><span class='obj identifier id'>obj</span><span class='comma token'>,</span> <span class='options identifier id'>options</span><span class='rparen token'>)</span>
  <span class='destroy_warning identifier id'>destroy_warning</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:destroy_warning</span><span class='rbrack token'>]</span> <span class='orop op'>||</span> <span class='string val'>&quot;Are you sure?&quot;</span>
  <span class='klass identifier id'>klass</span> <span class='assign token'>=</span> <span class='obj identifier id'>obj</span><span class='dot token'>.</span><span class='class identifier id'>class</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='dot token'>.</span><span class='underscore identifier id'>underscore</span>
  <span class='links identifier id'>links</span> <span class='assign token'>=</span> <span class='dstring node'>%w(show edit destroy)</span><span class='dot token'>.</span><span class='collect identifier id'>collect</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='action identifier id'>action</span><span class='bitor op'>|</span>
    <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:exclude</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:exclude</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span> <span class='unless unless_mod kw'>unless</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:exclude</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='Array constant id'>Array</span><span class='rparen token'>)</span>
    <span class='next next kw'>next</span> <span class='if if_mod kw'>if</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:exclude</span><span class='rbrack token'>]</span> <span class='andop op'>&amp;&amp;</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:exclude</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='include? fid id'>include?</span><span class='lparen token'>(</span><span class='action identifier id'>action</span><span class='dot token'>.</span><span class='to_sym identifier id'>to_sym</span><span class='rparen token'>)</span>
    <span class='img identifier id'>img</span> <span class='assign token'>=</span> <span class='image_tag identifier id'>image_tag</span><span class='lparen token'>(</span><span class='dstring node'>&quot;#{action}.png&quot;</span><span class='rparen token'>)</span>
    <span class='key identifier id'>key</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;#{obj.class.table_name}##{action}&quot;</span>
    <span class='case case kw'>case</span> <span class='action identifier id'>action</span>
    <span class='when when kw'>when</span> <span class='string val'>&quot;show&quot;</span>
      <span class='link_to_if_auth identifier id'>link_to_if_auth</span><span class='lparen token'>(</span><span class='img identifier id'>img</span><span class='comma token'>,</span> <span class='send identifier id'>send</span><span class='lparen token'>(</span><span class='dstring node'>&quot;#{klass}_path&quot;</span><span class='comma token'>,</span> <span class='obj identifier id'>obj</span><span class='rparen token'>)</span><span class='comma token'>,</span> <span class='key identifier id'>key</span><span class='comma token'>,</span> <span class='obj identifier id'>obj</span><span class='comma token'>,</span> <span class='symbol val'>:title</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;View&quot;</span><span class='rparen token'>)</span>
    <span class='when when kw'>when</span> <span class='string val'>&quot;edit&quot;</span>
      <span class='link_to_if_auth identifier id'>link_to_if_auth</span><span class='lparen token'>(</span><span class='img identifier id'>img</span><span class='comma token'>,</span> <span class='send identifier id'>send</span><span class='lparen token'>(</span><span class='dstring node'>&quot;edit_#{klass}_path&quot;</span><span class='comma token'>,</span> <span class='obj identifier id'>obj</span><span class='rparen token'>)</span><span class='comma token'>,</span> <span class='key identifier id'>key</span><span class='comma token'>,</span> <span class='obj identifier id'>obj</span><span class='comma token'>,</span> <span class='symbol val'>:title</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;Edit&quot;</span><span class='rparen token'>)</span>
    <span class='when when kw'>when</span> <span class='string val'>&quot;destroy&quot;</span>
      <span class='link_to_if_auth identifier id'>link_to_if_auth</span><span class='lparen token'>(</span><span class='img identifier id'>img</span><span class='comma token'>,</span> <span class='obj identifier id'>obj</span><span class='comma token'>,</span> <span class='key identifier id'>key</span><span class='comma token'>,</span> <span class='obj identifier id'>obj</span><span class='comma token'>,</span> <span class='symbol val'>:method</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='symbol val'>:delete</span><span class='comma token'>,</span> <span class='symbol val'>:confirm</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='destroy_warning identifier id'>destroy_warning</span><span class='comma token'>,</span> <span class='symbol val'>:title</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;Delete&quot;</span><span class='rparen token'>)</span>
    <span class='end end kw'>end</span>
  <span class='end end kw'>end</span><span class='dot token'>.</span><span class='compact identifier id'>compact</span>
  <span class='links identifier id'>links</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='string val'>&quot;&quot;</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='html_safe identifier id'>html_safe</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="basic_form-instance_method">
  
    - (<tt>Object</tt>) <strong>basic_form</strong>(obj, &amp;block) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
draws a basic form for the given object
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


43
44
45
46
47
48
49
50
51
52
53</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 43</span>

<span class='def def kw'>def</span> <span class='basic_form identifier id'>basic_form</span><span class='lparen token'>(</span><span class='obj identifier id'>obj</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='block identifier id'>block</span><span class='rparen token'>)</span>
  <span class='form_for identifier id'>form_for</span><span class='lparen token'>(</span><span class='obj identifier id'>obj</span><span class='rparen token'>)</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='f identifier id'>f</span><span class='bitor op'>|</span>
    <span class='f identifier id'>f</span><span class='dot token'>.</span><span class='mode identifier id'>mode</span> <span class='assign token'>=</span> <span class='controller identifier id'>controller</span><span class='dot token'>.</span><span class='action_name identifier id'>action_name</span><span class='dot token'>.</span><span class='to_sym identifier id'>to_sym</span>
    <span class='comment val'># get the fields spec</span>
    <span class='spec identifier id'>spec</span> <span class='assign token'>=</span> <span class='block identifier id'>block</span><span class='dot token'>.</span><span class='call identifier id'>call</span><span class='lparen token'>(</span><span class='f identifier id'>f</span><span class='rparen token'>)</span>
    <span class='comment val'># if fields doesn't have sections, create one big section </span>
    <span class='spec identifier id'>spec</span><span class='lbrack token'>[</span><span class='symbol val'>:sections</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='lbrace token'>{</span><span class='symbol val'>:fields</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='spec identifier id'>spec</span><span class='lbrack token'>[</span><span class='symbol val'>:fields</span><span class='rbrack token'>]</span><span class='rbrace token'>}</span><span class='rbrack token'>]</span> <span class='unless unless_mod kw'>unless</span> <span class='spec identifier id'>spec</span><span class='lbrack token'>[</span><span class='symbol val'>:sections</span><span class='rbrack token'>]</span>
    <span class='comment val'># render the form and return it</span>
    <span class='render identifier id'>render</span><span class='lparen token'>(</span><span class='string val'>&quot;layouts/basic_form&quot;</span><span class='comma token'>,</span> <span class='symbol val'>:f</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='f identifier id'>f</span><span class='comma token'>,</span> <span class='symbol val'>:spec</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='spec identifier id'>spec</span><span class='comma token'>,</span> <span class='symbol val'>:obj</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='obj identifier id'>obj</span><span class='rparen token'>)</span>
  <span class='end end kw'>end</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="batch_op_link-instance_method">
  
    - (<tt>Object</tt>) <strong>batch_op_link</strong>(options) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
creates a link to a batch operation options include :action (e.g.
forms#add_questions), :id, :format, :name (name of the link)
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


94
95
96
97
98
99
100
101
102
103</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 94</span>

<span class='def def kw'>def</span> <span class='batch_op_link identifier id'>batch_op_link</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='rparen token'>)</span>
  <span class='url_bits identifier id'>url_bits</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span>
  <span class='url_bits identifier id'>url_bits</span><span class='lbrack token'>[</span><span class='symbol val'>:controller</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='url_bits identifier id'>url_bits</span><span class='lbrack token'>[</span><span class='symbol val'>:action</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:action</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='split identifier id'>split</span><span class='lparen token'>(</span><span class='string val'>&quot;#&quot;</span><span class='rparen token'>)</span>
  <span class='url_bits identifier id'>url_bits</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span> <span class='if if_mod kw'>if</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:id</span><span class='rbrack token'>]</span>
  <span class='url_bits identifier id'>url_bits</span><span class='lbrack token'>[</span><span class='symbol val'>:format</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:format</span><span class='rbrack token'>]</span> <span class='if if_mod kw'>if</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:format</span><span class='rbrack token'>]</span>
  <span class='path identifier id'>path</span> <span class='assign token'>=</span> <span class='url_for identifier id'>url_for</span><span class='lparen token'>(</span><span class='url_bits identifier id'>url_bits</span><span class='rparen token'>)</span>
  <span class='button_to_if_auth identifier id'>button_to_if_auth</span><span class='lparen token'>(</span><span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:name</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='string val'>&quot;#&quot;</span><span class='comma token'>,</span> <span class='options identifier id'>options</span><span class='lbrack token'>[</span><span class='symbol val'>:action</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='nil nil kw'>nil</span><span class='comma token'>,</span> 
    <span class='symbol val'>:onclick</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='dstring node'>&quot;batch_submit({path: '#{path}', confirm: '#{options[:confirm]}'}); return false;&quot;</span><span class='comma token'>,</span>
    <span class='symbol val'>:class</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;batch_op_link&quot;</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="button_to_if_auth-instance_method">
  
    - (<tt>Object</tt>) <strong>button_to_if_auth</strong>(label, url, action, object = nil, *args) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
same as link_to_if_auth but for button_to
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


38
39
40</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 38</span>

<span class='def def kw'>def</span> <span class='button_to_if_auth identifier id'>button_to_if_auth</span><span class='lparen token'>(</span><span class='label identifier id'>label</span><span class='comma token'>,</span> <span class='url identifier id'>url</span><span class='comma token'>,</span> <span class='action identifier id'>action</span><span class='comma token'>,</span> <span class='object identifier id'>object</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='args identifier id'>args</span><span class='rparen token'>)</span>
  <span class='authorized? fid id'>authorized?</span><span class='lparen token'>(</span><span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='action identifier id'>action</span><span class='comma token'>,</span> <span class='symbol val'>:object</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='object identifier id'>object</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='button_to identifier id'>button_to</span><span class='lparen token'>(</span><span class='label identifier id'>label</span><span class='comma token'>,</span> <span class='url identifier id'>url</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='args identifier id'>args</span><span class='rparen token'>)</span> <span class='colon op'>:</span> <span class='string val'>&quot;&quot;</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="fix_error_messages-instance_method">
  
    - (<tt>Object</tt>) <strong>fix_error_messages</strong>(msgs) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
applies any customizations to automatically generated form error messages
called from layouts/flash
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


26
27
28
29
30</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 26</span>

<span class='def def kw'>def</span> <span class='fix_error_messages identifier id'>fix_error_messages</span><span class='lparen token'>(</span><span class='msgs identifier id'>msgs</span><span class='rparen token'>)</span>
  <span class='msgs identifier id'>msgs</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span><span class='lparen token'>(</span><span class='string val'>&quot;Answers are invalid&quot;</span><span class='comma token'>,</span> <span class='string val'>&quot;One or more answers are invalid&quot;</span><span class='rparen token'>)</span>
  <span class='msgs identifier id'>msgs</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span><span class='lparen token'>(</span><span class='string val'>&quot;@ please.&quot;</span><span class='comma token'>,</span> <span class='string val'>&quot;@&quot;</span><span class='rparen token'>)</span>
  <span class='msgs identifier id'>msgs</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span><span class='lparen token'>(</span><span class='string val'>&quot;look like an email address.&quot;</span><span class='comma token'>,</span> <span class='string val'>&quot;look like an email address&quot;</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="flash_and_form_errors-instance_method">
  
    - (<tt>Object</tt>) <strong>flash_and_form_errors</strong>(object = nil) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
renders the flash message and any form errors for the given activerecord
object
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


20
21
22</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 20</span>

<span class='def def kw'>def</span> <span class='flash_and_form_errors identifier id'>flash_and_form_errors</span><span class='lparen token'>(</span><span class='object identifier id'>object</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span><span class='rparen token'>)</span>
  <span class='render identifier id'>render</span><span class='lparen token'>(</span><span class='string val'>&quot;layouts/flash&quot;</span><span class='comma token'>,</span> <span class='symbol val'>:flash</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='flash identifier id'>flash</span><span class='comma token'>,</span> <span class='symbol val'>:object</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='object identifier id'>object</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="index_table-instance_method">
  
    - (<tt>Object</tt>) <strong>index_table</strong>(klass, objects) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
renders an index table for the given class and list of objects
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 111</span>

<span class='def def kw'>def</span> <span class='index_table identifier id'>index_table</span><span class='lparen token'>(</span><span class='klass identifier id'>klass</span><span class='comma token'>,</span> <span class='objects identifier id'>objects</span><span class='rparen token'>)</span>
  <span class='comment val'># figure out of we're dealing with a pagination collection or just a normal array</span>
  <span class='paginated identifier id'>paginated</span> <span class='assign token'>=</span> <span class='objects identifier id'>objects</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='WillPaginate constant id'>WillPaginate</span><span class='colon2 op'>::</span><span class='Collection constant id'>Collection</span><span class='rparen token'>)</span> <span class='andop op'>&amp;&amp;</span> 
    <span class='objects identifier id'>objects</span><span class='dot token'>.</span><span class='total_entries identifier id'>total_entries</span> <span class='neq op'>!=</span> <span class='integer val'>0</span> <span class='andop op'>&amp;&amp;</span> <span class='objects identifier id'>objects</span><span class='dot token'>.</span><span class='total_entries identifier id'>total_entries</span> <span class='gt op'>&gt;</span> <span class='objects identifier id'>objects</span><span class='dot token'>.</span><span class='size identifier id'>size</span>
  
  <span class='comment val'># get links from class' helper</span>
  <span class='links identifier id'>links</span> <span class='assign token'>=</span> <span class='send identifier id'>send</span><span class='lparen token'>(</span><span class='dstring node'>&quot;#{klass.table_name}_index_links&quot;</span><span class='comma token'>,</span> <span class='objects identifier id'>objects</span><span class='rparen token'>)</span>
  <span class='comment val'># if there are any batch links, insert the 'select all' link</span>
  <span class='batch_ops identifier id'>batch_ops</span> <span class='assign token'>=</span> <span class='notop op'>!</span><span class='links identifier id'>links</span><span class='dot token'>.</span><span class='reject identifier id'>reject</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='l identifier id'>l</span><span class='bitor op'>|</span> <span class='notop op'>!</span><span class='l identifier id'>l</span><span class='dot token'>.</span><span class='match identifier id'>match</span><span class='lparen token'>(</span><span class='regexp val'>/class=&quot;batch_op_link&quot;/</span><span class='rparen token'>)</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='empty? fid id'>empty?</span>
  <span class='links identifier id'>links</span><span class='dot token'>.</span><span class='insert identifier id'>insert</span><span class='lparen token'>(</span><span class='integer val'>0</span><span class='comma token'>,</span> <span class='select_all_link identifier id'>select_all_link</span><span class='rparen token'>)</span> <span class='if if_mod kw'>if</span> <span class='batch_ops identifier id'>batch_ops</span>
  
  <span class='comment val'># render, getting fields and checking if there are no objects at all</span>
  <span class='render identifier id'>render</span><span class='lparen token'>(</span><span class='string val'>&quot;layouts/index_table&quot;</span><span class='comma token'>,</span>
    <span class='symbol val'>:klass</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='klass identifier id'>klass</span><span class='comma token'>,</span>
    <span class='symbol val'>:objects</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='objects identifier id'>objects</span><span class='comma token'>,</span>
    <span class='symbol val'>:links</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='join_links identifier id'>join_links</span><span class='lparen token'>(</span><span class='mult op'>*</span><span class='links identifier id'>links</span><span class='dot token'>.</span><span class='flatten identifier id'>flatten</span><span class='rparen token'>)</span><span class='comma token'>,</span>
    <span class='symbol val'>:paginated</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='paginated identifier id'>paginated</span><span class='comma token'>,</span>
    <span class='symbol val'>:human_class_name</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='klass identifier id'>klass</span><span class='dot token'>.</span><span class='name identifier id'>name</span><span class='dot token'>.</span><span class='underscore identifier id'>underscore</span><span class='dot token'>.</span><span class='humanize identifier id'>humanize</span><span class='dot token'>.</span><span class='downcase identifier id'>downcase</span><span class='comma token'>,</span>
    <span class='symbol val'>:fields</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='send identifier id'>send</span><span class='lparen token'>(</span><span class='dstring node'>&quot;#{klass.table_name}_index_fields&quot;</span><span class='rparen token'>)</span><span class='comma token'>,</span>
    <span class='symbol val'>:batch_ops</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='batch_ops identifier id'>batch_ops</span>
  <span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="join_links-instance_method">
  
    - (<tt>Object</tt>) <strong>join_links</strong>(*links) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
joins a set of links together with pipe characters, ignoring any blank ones
for use with link_to_if_auth
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


57
58
59</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 57</span>

<span class='def def kw'>def</span> <span class='join_links identifier id'>join_links</span><span class='lparen token'>(</span><span class='mult op'>*</span><span class='links identifier id'>links</span><span class='rparen token'>)</span>
  <span class='links identifier id'>links</span><span class='dot token'>.</span><span class='reject identifier id'>reject</span><span class='lbrace token'>{</span><span class='bitor op'>|</span><span class='l identifier id'>l</span><span class='bitor op'>|</span> <span class='l identifier id'>l</span><span class='dot token'>.</span><span class='blank? fid id'>blank?</span><span class='rbrace token'>}</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='string val'>&quot; | &quot;</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='html_safe identifier id'>html_safe</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="link_to_if_auth-instance_method">
  
    - (<tt>Object</tt>) <strong>link_to_if_auth</strong>(label, url, action, object = nil, *args) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
renders a link only if the current user is authorized for the specified
action
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


33
34
35</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 33</span>

<span class='def def kw'>def</span> <span class='link_to_if_auth identifier id'>link_to_if_auth</span><span class='lparen token'>(</span><span class='label identifier id'>label</span><span class='comma token'>,</span> <span class='url identifier id'>url</span><span class='comma token'>,</span> <span class='action identifier id'>action</span><span class='comma token'>,</span> <span class='object identifier id'>object</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='args identifier id'>args</span><span class='rparen token'>)</span>
  <span class='authorized? fid id'>authorized?</span><span class='lparen token'>(</span><span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='action identifier id'>action</span><span class='comma token'>,</span> <span class='symbol val'>:object</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='object identifier id'>object</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='link_to identifier id'>link_to</span><span class='lparen token'>(</span><span class='label identifier id'>label</span><span class='comma token'>,</span> <span class='url identifier id'>url</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='args identifier id'>args</span><span class='rparen token'>)</span> <span class='colon op'>:</span> <span class='string val'>&quot;&quot;</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="place_field-instance_method">
  
    - (<tt>Object</tt>) <strong>place_field</strong>(form) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
renders a place field in a form
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


62
63
64</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 62</span>

<span class='def def kw'>def</span> <span class='place_field identifier id'>place_field</span><span class='lparen token'>(</span><span class='form identifier id'>form</span><span class='rparen token'>)</span>
  <span class='render identifier id'>render</span><span class='lparen token'>(</span><span class='string val'>&quot;places/place_field&quot;</span><span class='comma token'>,</span> <span class='symbol val'>:form</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='form identifier id'>form</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="reqd_sym-instance_method">
  
    - (<tt>Object</tt>) <strong>reqd_sym</strong>(condition = true) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
renders the standard &#8216;required&#8217; symbol, which is an asterisk
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


67
68
69</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 67</span>

<span class='def def kw'>def</span> <span class='reqd_sym identifier id'>reqd_sym</span><span class='lparen token'>(</span><span class='condition identifier id'>condition</span> <span class='assign token'>=</span> <span class='true true kw'>true</span><span class='rparen token'>)</span>
  <span class='lparen token'>(</span><span class='condition identifier id'>condition</span> <span class='integer val'>? </span><span class='string val'>'&lt;div class=&quot;reqd_sym&quot;&gt;*&lt;/div&gt;'</span> <span class='colon op'>:</span> <span class='string val'>''</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='html_safe identifier id'>html_safe</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="select_all_link-instance_method">
  
    - (<tt>Object</tt>) <strong>select_all_link</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>
creates a link to select all the checkboxes in an index table
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


106
107
108</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/helpers/application_helper.rb', line 106</span>

<span class='def def kw'>def</span> <span class='select_all_link identifier id'>select_all_link</span>
  <span class='button_to identifier id'>button_to</span><span class='lparen token'>(</span><span class='string val'>&quot;Select All&quot;</span><span class='comma token'>,</span> <span class='string val'>&quot;#&quot;</span><span class='comma token'>,</span> <span class='symbol val'>:onclick</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;batch_select_all(); return false&quot;</span><span class='comma token'>,</span> <span class='symbol val'>:id</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>&quot;select_all_link&quot;</span><span class='rparen token'>)</span>
<span class='end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Thu Dec  8 13:43:17 2011 by 
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.7.3 (ruby-1.8.7).
</div>

  </body>
</html>